#/usr/bin/python
#encoding:utf-8

# app类
import os


class LanchTime(object):
    def __init__(self, content='', startTime=0):
        self.content = content
        self.startTime = startTime

    # 启动App
    def LaunchApp(self):
        cmd = 'adb shell am start -W -n com.android.brower/.BrowerActivity'
        self.content = os.popen(cmd)
    # 停止App
    def StopApp(self):
        # 冷启动
        #cmd = 'adb shell am force-stop com.android.browser'
        # 热启动
        cmd = 'adb shell input keyevent 3'
        os.popen(cmd)
    # 获取启动时间
    def GetLaunchTime(self):
        for line in self.content.readlines():
            if "ThisTime" in line:
                self.startTime = line.split(":")[1]
                break
        return self.startTime
